package day10test;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int money;
        //金额是否在范围的判断
        while (true) {
            System.out.println("请输入金额");
            money = sc.nextInt();
            if (money >= 0 && money <= 9999999) {
                break;
            } else {
                System.out.println("输入错误金额");
            }
        }

        //提取输入数字的每一位  放入方法引索替换 成大写并拼接
        String capitalNumber = "";
        while (true) {
            int ge = money % 10;
            capitalNumber = getCapitalNumber(ge) + capitalNumber;
            money = money / 10;
            if (money == 0) {
                break;
            }
        }
        //不满7 补零
        int count = 7 - capitalNumber.length();
        for (int i = 0; i < count; i++) {
            capitalNumber = "零" + capitalNumber;
        }
        String[] arr = {"佰", "拾", "万", "仟", "佰", "拾", "元"};


        String result = "";
        for (int i = 0; i < capitalNumber.length(); i++) {
            char c = capitalNumber.charAt(i);
            result = result + c + arr[i];

        }
        System.out.print(result);
    }


    //capital 大写   capital capital capital capital capital
    public static String getCapitalNumber(int number) {
        String[] arr = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖",};
        return arr[number];
    }

}
